package com.antis.olsl.magic.adapter;

import android.graphics.Color;
import android.widget.TextView;

import com.antis.olsl.magic.R;
import com.antis.olsl.magic.response.StaveSummaryResp;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.List;

public class StaveAdapter extends BaseQuickAdapter<StaveSummaryResp.ContentBean.ShopListBean, BaseViewHolder> {
    public StaveAdapter(int layoutResId, @Nullable List<StaveSummaryResp.ContentBean.ShopListBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(@NotNull BaseViewHolder helper, StaveSummaryResp.ContentBean.ShopListBean bean) {
        helper.setText(R.id.text_store_name, bean.shopName);
        TextView textStatus = helper.getView(R.id.text_status);
        // 1:盈利 2:亏损 3:达成目标 4:未达目标
        String status;
        String statusColor;
        switch (bean.status) {
            case 1:
                status = "盈利";
                statusColor = "#2cce91";
                break;
            case 2:
                status = "亏损";
                statusColor = "#f3504f";
                break;
            case 3:
                status = "达成目标";
                statusColor = "#f3af11";
                break;
            case 4:
                status = "未达目标";
                statusColor = "#a3abb5";
                break;
            default:
                status = "";
                statusColor = "#2cce91";
                break;
        }
        textStatus.setText(status);
        textStatus.setTextColor(Color.parseColor(statusColor));
    }
}
